<?php
include_once "lib/config.php";
include_once "header.php";

if(isset($_REQUEST['cpid']) && $_REQUEST['cpid']>0)
{
	$conditionarr=array(":Comp_Page_ID"=>$_REQUEST['cpid']);
    $pageinfo=DB::fetch_array(DB::query("select af_company_page.*, acpm.count_members as count_members, acpmedia.count_media as count_media, af_company_types.company_type_name, af_users.Full_Name from  af_users, af_company_types,  af_company_page left join (SELECT  comp_page_id , count( comp_page_id ) as count_members FROM `af_company_page_members` group by  comp_page_id) as acpm on af_company_page.Comp_Page_ID=acpm.comp_page_id left join (SELECT  comp_page_id , count( comp_page_id ) as count_media FROM `af_company_page_media` where Status=1 group by  Comp_Page_ID) as acpmedia on af_company_page.Comp_Page_ID=acpmedia.Comp_Page_ID where  af_company_page.User_ID=af_users.User_ID and af_company_page.Comp_Type_ID=af_company_types.company_type_id and af_users.Activation_Status='Active' and af_company_page.Status!=2 and af_company_page.Comp_Page_ID=:Comp_Page_ID",$conditionarr));
    
    if(isset($pageinfo[0]))
    {
        $data=$pageinfo[0];
    }
    else
    {
        $data=array();
    }
}

?>
  		<div class="container_12" id="main_div">
			<br>
			<div class="grid_12" >
		    	<?php
            	if(isset($msg_success) && $msg_success!="")
            	{
            	?>
                <div>
                    <span class="notification n-success"><?php echo $msg_success; ?></span>
                </div>
                <?php
                }
                if(isset($msg_error) && $msg_error!="")
                {
                ?>
                <span class="notification n-error"><?php echo $msg_error; ?></span>
                <?php
				}
                ?>
		        <div class="module" >
		        		
		             <h2><span onclick="toggle_div('basic_body','toogleimg');" ><img src="images/desc.gif" height="5px" id="toogleimg">&nbsp;&nbsp;Company Page Details</span></h2>
		                
		             <div class="module-body" id="basic_body">
		                
		                  	<p>
		                        <label>Company Page Name:</label>
		                        <a href="../page.php?page=<?php echo $data["Page_Slug"]; ?>" target="_blank"><?php echo $data['Comp_Page_Name']; ?></a>
		                    </p>
		                    <p>
		                        <label>Company Page Type:</label>
		                        <?php echo $data['company_type_name']; ?>
		                    </p>
		                    <p>
		                        <label>User Name:</label>
		                        <?php echo $data['Full_Name']; ?>
		                    </p>
		                    <p>
		                        <label>Company Address:</label>
		                        <?php if(isset($data['Comp_Address'])){echo $data['Comp_Address'];} else { echo "-"; } ?>
		                    </p>
		                    <p>
		                        <label>Company City:</label>
		                        <?php if(isset($data['Comp_City'])){echo $data['Comp_City'];} else { echo "-"; } ?>
		                    </p>
		                    <p>
		                        <label>Company State:</label>
		                        <?php if(isset($data['Comp_State'])){echo $data['Comp_State'];} else { echo "-"; } ?>
		                    </p>
		                    <p>
		                        <label>Company Zip:</label>
		                        <?php if(isset($data['Comp_Zip'])){echo $data['Comp_Zip'];} else { echo "-"; } ?>
		                    </p>
		                    <p>
		                        <label>Company Phone:</label>
		                        <?php if(isset($data['Comp_Phone'])){echo $data['Comp_Phone'];} else { echo "-"; } ?>
		                    </p>
		                    <p>
		                        <label>Create Date:</label>
		                        <?php if(isset($data['Create_Date'])){echo date("d/m/Y",trim($data['Comp_Phone']));} else { echo "-"; } ?>
		                    </p>
		                    <p>
		                        <label>Total Members:</label>
		                        <?php if(isset($data['count_members']) && $data["count_members"]>0){ ?><a href="view_page_members.php?cpid=<?php echo $data["Comp_Page_ID"]; ?>"><?php echo $data["count_members"]; ?></a><?php } else { echo "0"; } ?>
		                    </p>
		                    <p>
		                        <label>Total Media:</label>
		                        <?php if(isset($data['count_media']) && $data["count_media"]>0){ ?><a href="view_page_media.php?cpid=<?php echo $data["Comp_Page_ID"]; ?>"><?php echo $data["count_media"]; ?></a><?php } else { echo "0"; } ?>
		                    </p>
		                    <p>
		                    
		             </div> <!-- End .module-body -->
		
		        </div>  <!-- End .module -->
				
		    </div>
		    
		    <div class="grid_12">
		    <fieldset>
		    	&nbsp;
		    	<input type="hidden" id="entertainment_id" name="entertainment_id" value="<?php if(isset($_POST['entertainment_id'])){ echo $_POST['entertainment_id']; } ?>">
		        <input class="submit-green" type="submit" name="save" value="Submit" /> 
		        <input class="submit-gray" type="button" value="Back" onclick="window.location='entertainments.php'" />
		    </fieldset>
		    </div>
		    <div style="clear:both;"></div>    
        </div> <!-- End .container_12 -->
		
<?php include_once("footer.php"); ?>           
<?php
if(isset($msg_success) && $msg_success!="")
{
	$notymessage=$msg_success;
	$msgtype="success";
}
else if(isset($msg_error) && $msg_error!="")
{
	$msgtype="error";
	$notymessage=$msg_error;
}
else
{
	$msgtype="";
}
if($msgtype!="")
{
?>        
<script language="javascript">
	$(document).ready(function(){
		
		var options = $.parseJSON('{"text":"<?php echo $notymessage; ?>","layout":"top","type":"<?php echo $msgtype; ?>"}');
		noty(options);
		
	});
</script>  
<?php
}
?>       